package com.rongshu.view.userInfo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.rongshu.R;
import com.rongshu.view.base.BaseActivity;
import com.widget.EditTextWithDel;
import com.widget.titlebar.ImmersionBar;

import butterknife.BindView;
import butterknife.OnClick;

import static com.rongshu.utils.Constant.INTENT_FUNCTIONS;
import static com.rongshu.utils.Constant.INTENT_MESSAGE;
import static com.rongshu.utils.Constant.INTENT_TITLE;

/**
 * 修改资料
 */
public class AlterInfomationActivity extends BaseActivity {
    @BindView(R.id.txt_top_title)
    TextView txt_top_title;//标题
    @BindView(R.id.txt_top_function)
    TextView txt_top_function;//功能
    @BindView(R.id.edtChange)
    EditTextWithDel edtChange;

    private String title, function, message;

    @Override
    protected int initLayout() {
        return R.layout.activity_alter_infomation_view;
    }

    @Override
    protected void initView() {
        //获取意图中的数据
        Intent intent = getIntent();
        title = intent.getStringExtra(INTENT_TITLE);
        function = intent.getStringExtra(INTENT_FUNCTIONS);
        message = intent.getStringExtra(INTENT_MESSAGE);
        //设置title
        txt_top_title.setText(title);
        txt_top_function.setVisibility(View.VISIBLE);
        //设置fuction
        txt_top_function.setText(function);
        //设置hint
        edtChange.setHint(message);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void updateViews(boolean isRefresh) {

    }


    @OnClick({R.id.layout_back, R.id.txt_top_function})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.layout_back:
                showKeyboard(false);
                onBackPressed();
                break;
            case R.id.txt_top_function:
                String message = edtChange.getText().toString().trim();
                if (TextUtils.isEmpty(message)) {
                    toast(getString(R.string.please_input_message));
                    return;
                }
                showKeyboard(false);
                Intent intent = new Intent();
                intent.putExtra(INTENT_MESSAGE, message);
                setResult(RESULT_OK, intent);
                finish();
                break;
        }
    }


    @Override
    public void onBackPressed() {
        super.onBackPressed();
    }
}
